<%--
  Created by IntelliJ IDEA.
  User: Xuejun
  Date: 2024/12/2
  Time: 14:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="cn.gxj62.mysql" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="cn.gxj62.Student" %>
<%@ page import="java.util.ArrayList" %>
<html>
<head>
    <title>删除学生</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/4.0.0-beta.2/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style/studentCard.css">
    <link rel="stylesheet" type="text/css" href="style/page.css">
    <style>
        input[type="submit"] {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

        input[type="submit"]:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
<%
    Connection con = mysql.SQLConnect();
    ArrayList<Student> students = null;
    if (con != null) {
        students = mysql.getStudents(con);
    }
%>
<h2>删除选中的学生</h2>
<form action="deleteStudent" method="post">
    <input type="submit" value="删除"/><a href="index.jsp">返回主页</a><br/>
    <div class="studentCard-container">
        <%
            if (students != null) {
                for (Student student : students) {
                    out.println("<table class='studentCard'>");
                    out.println("<tr>");
                    out.println("<td>是否删除:</td><td><input type='checkbox' name='bin' value=" + student.getId() + "></td>");
                    out.println("<tr>");
                    out.println("<td>学号:</td><td>" + student.getId() + "</td>");
                    out.println("</tr><tr>");
                    out.println("<td>姓名：</td><td>" + student.getName() + "</td>");
                    out.println("</tr><tr>");
                    out.println("<td>年龄：</td><td>" + student.getAge() + "</td>");
                    out.println("</tr><tr>");
                    out.println("<td>专业：</td><td>" + student.getMajor() + "</td>");
                    out.println("</tr><tr>");
                    out.println("<td>性别：</td><td>" + (student.getSex() ? "男" : "女") + "</td>");
                    out.println("</tr><tr>");
                    out.println("<td>是否班干：</td><td>" + (student.isLeader() ? "是" : "否") + "</td>");
                    out.println("</tr>");
                    out.println("</table>");
                }
            } else {
                out.println("没有学生信息");
            }
        %>
    </div>
</form>
</body>
</html>
